//
//  MainViewController.m
//  carSecretary
//
//  Created by huangliru on 14-9-4.
//  Copyright (c) 2014年 huangliru. All rights reserved.
//

#import "MainViewController.h"
#import "CameraViewController.h"
#import "PhotoViewController.h"
#import "CarMessageViewController.h"
#import "WarningViewController.h"
#import "AboutViewController.h"
#import "SetViewController.h"
@interface MainViewController ()

@end

@implementation MainViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //创建一个导航栏
    UINavigationBar *bar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 18, 320, 44)];
    //创建一个导航栏集合
    UINavigationItem *navigationItem = [[UINavigationItem alloc] initWithTitle:nil];
    //创建一个左边按钮
    UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleBordered target:self action:@selector(backButton)];
    //设置导航栏内容
    [navigationItem setTitle:@"主菜单"];
    //把导航栏集合添加入导航栏中，设置动画关闭
    [bar pushNavigationItem:navigationItem animated:NO];
    //把左按钮添加入导航栏集合中
    [navigationItem setLeftBarButtonItem:leftButton];
    bar.backgroundColor = [UIColor grayColor];
    [self.view addSubview:bar];
    
    // 摄像头按钮
    self.cameraButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    self.cameraButton.frame = CGRectMake(70, 92, 180, 40);
    self.cameraButton.tintColor = [UIColor blackColor];
    [self.cameraButton setTitle:@"摄像头" forState:UIControlStateNormal];
    [self.cameraButton setBackgroundImage:[UIImage imageNamed:@"213.png"] forState:UIControlStateNormal];
    [self.cameraButton addTarget:self action:@selector(cameraButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.cameraButton];
    
    // 即时照片按钮
    self.photoButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    self.photoButton.frame = CGRectMake(70, 172, 180, 40);
    self.photoButton.tintColor = [UIColor blackColor];
    [self.photoButton setTitle:@"即时照片" forState:UIControlStateNormal];
    [self.photoButton setBackgroundImage:[UIImage imageNamed:@"213.png"] forState:UIControlStateNormal];
    [self.photoButton addTarget:self action:@selector(photoButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.photoButton];
    
    // 车辆状态按钮
    self.carmessageButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    self.carmessageButton.frame = CGRectMake(70, 250, 180, 40);
    self.carmessageButton.tintColor = [UIColor blackColor];
    [self.carmessageButton setTitle:@"车辆状态" forState:UIControlStateNormal];
    [self.carmessageButton setBackgroundImage:[UIImage imageNamed:@"213.png"] forState:UIControlStateNormal];
    [self.carmessageButton addTarget:self action:@selector(carmessageButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.carmessageButton];
    
    // 报警系统按钮
    self.warnButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    self.warnButton.frame = CGRectMake(70, 332, 180, 40);
    self.warnButton.tintColor = [UIColor blackColor];
    [self.warnButton setTitle:@"报警系统" forState:UIControlStateNormal];
    [self.warnButton setBackgroundImage:[UIImage imageNamed:@"213.png"] forState:UIControlStateNormal];
    [self.warnButton addTarget:self action:@selector(warnButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.warnButton];
    
    // 关于我们按钮
    self.usButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    self.usButton.frame = CGRectMake(70, 413, 180, 40);
    self.usButton.tintColor = [UIColor blackColor];
    [self.usButton setTitle:@"关于我们" forState:UIControlStateNormal];
    [self.usButton setBackgroundImage:[UIImage imageNamed:@"213.png"] forState:UIControlStateNormal];
    [self.usButton addTarget:self action:@selector(usButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.usButton];
    
    // 设置按钮
    self.setButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    self.setButton.frame = CGRectMake(70, 493, 180, 40);
    self.setButton.tintColor = [UIColor blackColor];
    [self.setButton setTitle:@"设置" forState:UIControlStateNormal];
    [self.setButton setBackgroundImage:[UIImage imageNamed:@"213.png"] forState:UIControlStateNormal];
    [self.setButton addTarget:self action:@selector(setButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.setButton];
}
// 摄像头按钮
-(void)cameraButtonPress
{
    CameraViewController *cameraVC = [[CameraViewController alloc]init];
    [self presentViewController:cameraVC animated:NO completion:nil];
}
// 即时照片
-(void)photoButtonPress
{
    PhotoViewController *photoVC = [[PhotoViewController alloc]init];
    [self presentViewController:photoVC animated:NO completion:nil];
}
// 车辆状态
-(void)carmessageButtonPress
{
    CarMessageViewController *carVC = [[CarMessageViewController alloc]init];
    [self presentViewController:carVC animated:NO completion:nil];
}
// 报警系统
-(void)warnButtonPress
{
    WarningViewController *warnVC = [[WarningViewController alloc]init];
    [self presentViewController:warnVC animated:NO completion:nil];
}
// 关于我们
-(void)usButtonPress
{
    AboutViewController *aboutVC = [[AboutViewController alloc]init];
    [self presentViewController:aboutVC animated:NO completion:nil];
}
// 设置
-(void)setButtonPress
{
    SetViewController *setVC = [[SetViewController alloc]init];
    [self presentViewController:setVC animated:NO completion:nil];
}
// 导航栏返回按钮
-(void)backButton
{
    [self dismissViewControllerAnimated:NO completion:nil];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
